﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace Common.Core
{
	public class NamedTokenFormatter : IFormatProvider, ICustomFormatter
	{
		object IFormatProvider.GetFormat( Type formatType )
		{
			if ( formatType == typeof(ICustomFormatter) )
			{
				return this;
			}
			return null;
		}

		public string PropertyName { get; set; }

		string ICustomFormatter.Format( string format, object arg, IFormatProvider formatProvider )
		{
			ValueResolver resolver = new ValueResolver( arg, format );
			string result = resolver.Resolve().ToString();
			return result;
		}
	}
}
